(function(){"use strict";BX.namespace("BX.Fileman.Map");if(!!BX.Fileman.Map.Google){return}var t={};BX.Fileman.Map.instance=function(e,n){if(typeof t[e]==="undefined"){t[e]=new BX.Fileman.Map.Google(e,n)}return t[e]};BX.Fileman.Map.Google=function(t,e){this.mapId=t;this.mapInitHandlerList=[];this.param={multiple:!!e.multiple};this.mapData=[];this.map=null;this.deleteWindow=null;this.onMapInit(BX.proxy(this.init,this));this.editMode=true;this.waitForMap()};BX.Fileman.Map.Google.prototype.getMap=function(){return this.map};BX.Fileman.Map.Google.prototype.setEditMode=function(t){this.editMode=t};BX.Fileman.Map.Google.prototype.addListener=function(t){BX.addCustomEvent(this,"onGoogleMapChangeData",t)};BX.Fileman.Map.Google.prototype.waitForMap=function(){if(window.GLOBAL_arMapObjects===null){return}if(window.GLOBAL_arMapObjects[this.mapId]&&window.google&&window.google.maps&&window.google.maps.event){this.map=window.GLOBAL_arMapObjects[this.mapId];this.callOnMapInit()}else{setTimeout(BX.proxy(this.waitForMap,this),300)}};BX.Fileman.Map.Google.prototype.onMapInit=function(t){this.mapInitHandlerList.push(t)};BX.Fileman.Map.Google.prototype.callOnMapInit=function(){this.onMapInit=BX.delegate(function(t){t.apply(this,arguments)},this);for(var t=0;t<this.mapInitHandlerList.length;t++){this.onMapInit(this.mapInitHandlerList[t])}this.mapInitHandlerList=[];BX.onCustomEvent(this,"onGoolgeMapEditInit")};BX.Fileman.Map.Google.prototype.init=function(){BX.addCustomEvent("onAdminTabsChange",BX.delegate(function(){BXMapGoogleAfterShow(this.mapId)},this));this.map.addListener("click",BX.proxy(this.onMapClick,this))};BX.Fileman.Map.Google.prototype.onMapClick=function(t){if(this.editMode){if(this.param.multiple||this.mapData.length<=0){this.addPoint(t.latLng)}else{this.movePoint(0,t.latLng)}}BX.onCustomEvent(this,"onMapClick")};BX.Fileman.Map.Google.prototype.addPoint=function(t){var e=this.createPoint({lat:t.lat(),lng:t.lng()});this.callChangeEvent(e);return e};BX.Fileman.Map.Google.prototype.createPoint=function(t){var e=this.mapData.length;this.mapData.push(new BX.Fileman.Map.Google.Point(this,{lat:t.lat,lng:t.lng},e));return e};BX.Fileman.Map.Google.prototype.movePoint=function(t,e){this.mapData[t].moveTo({lat:e.lat(),lng:e.lng()});this.callChangeEvent(t)};BX.Fileman.Map.Google.prototype.removePoint=function(t){for(var e=0;e<this.mapData.length;e++){if(this.mapData[e]===t){this.mapData[e].clean();this.mapData=BX.util.deleteFromArray(this.mapData,e);this.callChangeEvent(e);break}}};BX.Fileman.Map.Google.prototype.panTo=function(t){this.getMap().panTo(t)};BX.Fileman.Map.Google.prototype.callChangeEvent=function(t){BX.onCustomEvent(this,"onGoogleMapChangeData",[this,this.mapData,t])};BX.Fileman.Map.Google.prototype.showDeleteWindow=function(t){if(this.deleteWindow===null){this.deleteWindow=new BX.Fileman.Map.Google.DeleteWindow(this)}this.deleteWindow.setMarker(t);this.deleteWindow.show()};BX.Fileman.Map.Google.Point=function(t,e,n){this.parent=t;this.index=n;this.latLng=new google.maps.LatLng(e.lat,e.lng);this.marker=new google.maps.Marker({position:this.latLng,map:this.parent.getMap(),draggable:true});this.marker.addListener("click",BX.proxy(this.click,this));this.marker.addListener("dragend",BX.proxy(this.dragend,this))};BX.Fileman.Map.Google.Point.prototype.getMarker=function(){return this.marker};BX.Fileman.Map.Google.Point.prototype.moveTo=function(t){this.latLng=new google.maps.LatLng(t.lat,t.lng);this.marker.setPosition(this.latLng)};BX.Fileman.Map.Google.Point.prototype.click=function(t){this.parent.showDeleteWindow(this)};BX.Fileman.Map.Google.Point.prototype.dragend=function(t){this.latLng=this.marker.getPosition();this.callChangeEvent();this.parent.callChangeEvent(this.index)};BX.Fileman.Map.Google.Point.prototype.callChangeEvent=function(){BX.onCustomEvent(this,"onGoogleMapPointChanged",[this.index,this.latLng])};BX.Fileman.Map.Google.Point.prototype.clean=function(){this.marker.setMap(null);this.marker=null};BX.Fileman.Map.Google.Point.prototype.getPosition=function(){return[this.latLng.lat(),this.latLng.lng()]};BX.Fileman.Map.Google.DeleteWindow=function(t){this.parent=t;this.infoWindow=null;this.marker=null};BX.Fileman.Map.Google.DeleteWindow.prototype.setMarker=function(t){this.marker=t};BX.Fileman.Map.Google.DeleteWindow.prototype.action=function(){this.parent.removePoint(this.marker)};BX.Fileman.Map.Google.DeleteWindow.prototype.show=function(){if(this.infoWindow===null){this.infoWindow=new google.maps.InfoWindow({content:BX.create("span",{text:BX.message("MGE_DELETE"),props:{className:"bx-mge-delete"},events:{click:BX.proxy(this.action,this)}})})}this.infoWindow.open(this.parent.getMap(),this.marker.getMarker())};BX.Main.UF.TypeGeo=function(){};BX.extend(BX.Main.UF.TypeGeo,BX.Main.UF.BaseType);BX.Main.UF.TypeGeo.USER_TYPE_ID="geo";BX.Main.UF.Factory.setTypeHandler(BX.Main.UF.TypeGeo.USER_TYPE_ID,BX.Main.UF.TypeGeo)})();
//# sourceMappingURL=script.map.js